
package CTRLayer;

import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;


public class CtrSale {
    

    public CtrSale() {

    }

    public ArrayList<SalesOrder> getAllOrders() 
    {
        IFDBSalesOrder dbOrder = new DBSalesOrder();
	ArrayList<SalesOrder> allOrders = new ArrayList<SalesOrder>();
	allOrders = dbOrder.getAllOrders(false);
	return allOrders;
    }

    public SalesOrder findOrder(int salesOrderID) 
    {
	IFDBSalesOrder dbOrder = new DBSalesOrder();
	return dbOrder.findOrder(salesOrderID, true);
    }

    public int updateSalesOrder(int salesOrderID, String salesDate, double amount, boolean deliveryStatus, String deliveryDate, int customerID, int invoiceID) {
	IFDBSalesOrder dbOrder = new DBSalesOrder();
	SalesOrder order = new SalesOrder();
	order.setSalesOrderID(salesOrderID);
	order.setSalesDate(salesDate);
       	order.setAmount(amount);
	order.setDeliveryStatus(deliveryStatus);
	order.setDeliveryDate(deliveryDate);
	order.setCustomerID(customerID);
	order.setInvoiceID(invoiceID);
	return dbOrder.updateSalesOrder(order);
        }

        public void insertSalesOrder(SalesOrder salesObj) 
    {
	IFDBSalesOrder dbSale = new DBSalesOrder();
        dbSale.insertSalesOrder(salesObj);
    }
        public int deleteSalesOrder(int salesOrderID) {
	IFDBSalesOrder dbOrder = new DBSalesOrder();
	return dbOrder.deleteOrder(salesOrderID);
      }
     
        
           
        
}
